package com.able.wanandroid.module.home;

import android.support.annotation.Nullable;

import com.able.wanandroid.R;
import com.able.wanandroid.bean.ArticleBean;
import com.able.wanandroid.utils.UIUtil;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;


/**
 * Created by Administrator on 2017/12/12.
 */

public class ArticleAdapter extends BaseQuickAdapter<ArticleBean.DataBean.DatasBean, BaseViewHolder> {
    public ArticleAdapter(int layoutResId, @Nullable List<ArticleBean.DataBean.DatasBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ArticleBean.DataBean.DatasBean item) {

        helper.setText(R.id.homeItemTitle, item.getTitle())
                .setText(R.id.homeItemAuthor, item.getAuthor())
                .setText(R.id.homeItemType, item.getChapterName())
                .addOnClickListener(R.id.homeItemType)
                .setTextColor(R.id.homeItemType, UIUtil.getColor(R.color.colorPrimary))
                .linkify(R.id.homeItemType)
                .setText(R.id.homeItemDate, item.getNiceDate())
                .setImageResource(R.id.homeItemLike, R.drawable.ic_action_no_like)
                .addOnClickListener(R.id.homeItemLike);
    }
}
